<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/includes/head.jsp"%>
<title>FeedDreamwork - 我的 Feed</title>
</head>
<body>
<%@ include file="/includes/top.jsp"%>
<div id="menu">
<ul>
	<li><a href="/">主页</a></li>
	<li class="active"><a href="/settings/listfeed.jsp">我的 Feed</a></li>
	<li><a href="/settings/addfeed.jsp">添加 Feed</a></li>
	<li><a href="/admin/admin.jsp">管理员工具</a></li>
	<%@ include file="/includes/userinfo.jsp"%>
</ul>
</div>
<div id="page">
<%
	FeedInfoRepository feedInfoRepo = new FeedInfoRepository();
	try {
		List<FeedInfo> feedInfos;
		if (userService.isUserAdmin())
			feedInfos = feedInfoRepo.getFeedInfos();
		else
			feedInfos = feedInfoRepo.getFeedInfos(user);
		for (FeedInfo feedInfo : feedInfos) {
%>
<h2 class="title"><a href="/feed/<%=feedInfo.getFeedId()%>"><%=feedInfo.getFeedId()%></a></h2>
<div class="entry">
<p><strong>Feed 地址：</strong><a
	href="/feed/<%=feedInfo.getFeedId()%>"><%=ApplicationProperty.HOST_NAME%>/feed/<%=feedInfo.getFeedId()%></a></p>
<p><strong>缓存时间：</strong><%=feedInfo.getFrequency()%> 秒</p>
<p><strong>Feed 格式：</strong><%=feedInfo.getTargetType()%></p>
<p><strong>处理指令：</strong></p>
<%
	for (String command : feedInfo.getProcessors()) {
%> <c:out value="<%=command%>" escapeXml="true" /><br />
<%
	}
%>
<p><strong>所有者：</strong><%=feedInfo.getOwner()%></p>
</div>
<div class="operation">
<form action="/settings/updatefeed" method="post">
<p><input type="hidden" name="feedid"
	value="<%=feedInfo.getFeedId()%>" /> <input type="hidden"
	name="redirect" value="<%=request.getRequestURL()%>"></input> <input
	type="submit" value="刷新" /></p>
</form>
<form action="/settings/editfeed.jsp" method="get">
<p><input type="hidden" name="feedid"
	value="<%=feedInfo.getFeedId()%>" /> <input type="submit" value="编辑" /></p>
</form>
<form action="/settings/deletefeed" method="post">
<p><input type="hidden" name="feedid"
	value="<%=feedInfo.getFeedId()%>" /> <input type="submit" value="删除" /></p>
</form>
<form action="/settings/subscribefeed" method="post">
<p><input type="hidden" name="feedid"
	value="<%=feedInfo.getFeedId()%>" /> <input type="submit" value="订阅" /></p>
</form>
<form action="/settings/publishfeed" method="post">
<p><input type="hidden" name="feedid"
	value="<%=feedInfo.getFeedId()%>" /> <input type="submit" value="推送更新" /></p>
</form>
</div>
<%
	}
	} finally {
		feedInfoRepo.close();
	}
%>
</div>
<%@ include file="/includes/footer.jsp"%>
</body>
</html>
